package com.aaa.controller.api;

import com.aaa.aop.annotation.Log;
import com.aaa.entity.CheckItem;
import com.aaa.entity.Dept;
import com.aaa.service.DeptService;
import com.aaa.vo.DeptVo;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * @BelongsPackage: com.aaa.controller.api
 * @Description:
 * @CreateTime: 2023-03-22  19:24
 * @Author: ql
 */
@RestController
@RequestMapping("/system/api/dept")
public class ApiDeptController {
    @Autowired
    private DeptService deptService;

    @GetMapping("list")
    public Result<List<Dept>> list(){
        return deptService.findAll();
    }
    @PostMapping("/queryByPage")
    public Result<IPage<Dept>> queryByPage(@RequestBody DeptVo deptVo){
       return deptService.queryByPage(deptVo);
    }
    @GetMapping("/queryById/{id}")
    public Result<Dept> queryById(@PathVariable Long id){
        return deptService.queryById(id);
    }
    @PostMapping("/addOrUpd")
    public Result<String> addOrUpd(@RequestBody Dept dept){
        return deptService.addOrUpdDept(dept);
    }

    @DeleteMapping("/deleteByIds/{id}")
    @Log(title = "批量删除",business_type = "1")
    public Result<String> deleteByIds(@PathVariable Long[] id){
        System.out.println("=========== " + Arrays.toString(id));
        return deptService.deleteByIds(id);
    }



}
